
export function initFuc(data,ball){
	let fuc = 'on' + data.alias;
	return obj[fuc](data,ball);
}
export function branchAnalysis(str,ball){
	let nub = [];
	switch(true){
		case (str.indexOf('红波') !== -1):
			var obj = {
				alias:'BoSe',
				color:'red'
			};
			nub = initFuc(obj,ball);
			break;
		case (str.indexOf('绿波') !== -1):
			var obj = {
				alias:'BoSe',
				color:'green'
			};
			nub = initFuc(obj,ball);
			break;
		case (str.indexOf('蓝波') !== -1):
			var obj = {
				alias:'BoSe',
				color:'blue'
			};
			nub = initFuc(obj,ball);
			break;
		case (str.indexOf('红大单') !== -1):
			var obj = {
				alias:'BoSeAndSides',
				color:'red',
				daXiao:'da',
				danShuang:'dan',
			};
			nub = initFuc(obj,ball);
			break;
		case (str.indexOf('红小单') !== -1):
			var obj = {
				alias:'BoSeAndSides',
				color:'red',
				daXiao:'xiao',
				danShuang:'dan',
			};
			nub = initFuc(obj,ball);
			break;
		case (str.indexOf('红大双') !== -1):
			var obj = {
				alias:'BoSeAndSides',
				color:'red',
				daXiao:'da',
				danShuang:'shuang',
			};
			nub = initFuc(obj,ball);
			break;
		case (str.indexOf('红小双') !== -1):
			var obj = {
				alias:'BoSeAndSides',
				color:'red',
				daXiao:'xiao',
				danShuang:'shuang',
			};
			nub = initFuc(obj,ball);
			break;
		case (str.indexOf('红合单') !== -1):
			var obj = {
				alias:'HeAndSides',
				color:'red',
				danShuang:'dan',
			};
			nub = initFuc(obj,ball);
			break;
		case (str.indexOf('红合双') !== -1):
			var obj = {
				alias:'HeAndSides',
				color:'red',
				danShuang:'shuang',
			};
			nub = initFuc(obj,ball);
			break;
		case (str.indexOf('红合大') !== -1):
			var obj = {
				alias:'HeAndSides',
				color:'red',
				daXiao:'da',
			};
			nub = initFuc(obj,ball);
			break;
		case (str.indexOf('红合小') !== -1):
			var obj = {
				alias:'HeAndSides',
				color:'red',
				daXiao:'xiao',
			};
			nub = initFuc(obj,ball);
			break;
		case (str.indexOf('红单') !== -1):
			var obj = {
				alias:'BoSeAndSides',
				color:'red',
				danShuang:'dan',
			};
			nub = initFuc(obj,ball);
			break;
		case (str.indexOf('红双') !== -1):
			var obj = {
				alias:'BoSeAndSides',
				color:'red',
				danShuang:'shuang',
			};
			nub = initFuc(obj,ball);
			break;
		case (str.indexOf('红大') !== -1):
			var obj = {
				alias:'BoSeAndSides',
				color:'red',
				daXiao:'da',
			};
			nub = initFuc(obj,ball);
			break;
		case (str.indexOf('红小') !== -1):
			var obj = {
				alias:'BoSeAndSides',
				color:'red',
				daXiao:'xiao',
			};
			nub = initFuc(obj,ball);
			break;
		case (str.indexOf('绿大单') !== -1):
			var obj = {
				alias:'BoSeAndSides',
				color:'green',
				daXiao:'da',
				danShuang:'dan',
			};
			nub = initFuc(obj,ball);
			break;
		case (str.indexOf('绿小单') !== -1):
			var obj = {
				alias:'BoSeAndSides',
				color:'green',
				daXiao:'xiao',
				danShuang:'dan',
			};
			nub = initFuc(obj,ball);
			break;
		case (str.indexOf('绿大双') !== -1):
			var obj = {
				alias:'BoSeAndSides',
				color:'green',
				daXiao:'da',
				danShuang:'shuang',
			};
			nub = initFuc(obj,ball);
			break;
		case (str.indexOf('绿小双') !== -1):
			var obj = {
				alias:'BoSeAndSides',
				color:'green',
				daXiao:'xiao',
				danShuang:'shuang',
			};
			nub = initFuc(obj,ball);
			break;
		case (str.indexOf('绿合单') !== -1):
			var obj = {
				alias:'HeAndSides',
				color:'green',
				danShuang:'dan',
			};
			nub = initFuc(obj,ball);
			break;
		case (str.indexOf('绿合双') !== -1):
			var obj = {
				alias:'HeAndSides',
				color:'green',
				danShuang:'shuang',
			};
			nub = initFuc(obj,ball);
			break;
		case (str.indexOf('绿合大') !== -1):
			var obj = {
				alias:'HeAndSides',
				color:'green',
				daXiao:'da',
			};
			nub = initFuc(obj,ball);
			break;
		case (str.indexOf('绿合小') !== -1):
			var obj = {
				alias:'HeAndSides',
				color:'green',
				daXiao:'xiao',
			};
			nub = initFuc(obj,ball);
			break;
		case (str.indexOf('绿单') !== -1):
			var obj = {
				alias:'BoSeAndSides',
				color:'green',
				danShuang:'dan',
			};
			nub = initFuc(obj,ball);
			break;
		case (str.indexOf('绿双') !== -1):
			var obj = {
				alias:'BoSeAndSides',
				color:'green',
				danShuang:'shuang',
			};
			nub = initFuc(obj,ball);
			break;
		case (str.indexOf('绿大') !== -1):
			var obj = {
				alias:'BoSeAndSides',
				color:'green',
				daXiao:'da',
			};
			nub = initFuc(obj,ball);
			break;
		case (str.indexOf('绿小') !== -1):
			var obj = {
				alias:'BoSeAndSides',
				color:'green',
				daXiao:'xiao',
			};
			nub = initFuc(obj,ball);
			break;
		case (str.indexOf('蓝大单') !== -1):
			var obj = {
				alias:'BoSeAndSides',
				color:'blue',
				daXiao:'da',
				danShuang:'dan',
			};
			nub = initFuc(obj,ball);
			break;
		case (str.indexOf('蓝小单') !== -1):
			var obj = {
				alias:'BoSeAndSides',
				color:'blue',
				daXiao:'xiao',
				danShuang:'dan',
			};
			nub = initFuc(obj,ball);
			break;
		case (str.indexOf('蓝大双') !== -1):
			var obj = {
				alias:'BoSeAndSides',
				color:'blue',
				daXiao:'da',
				danShuang:'shuang',
			};
			nub = initFuc(obj,ball);
			break;
		case (str.indexOf('蓝小双') !== -1):
			var obj = {
				alias:'BoSeAndSides',
				color:'blue',
				daXiao:'xiao',
				danShuang:'shuang',
			};
			nub = initFuc(obj,ball);
			break;
		case (str.indexOf('蓝合单') !== -1):
			var obj = {
				alias:'HeAndSides',
				color:'blue',
				danShuang:'dan',
			};
			nub = initFuc(obj,ball);
			break;
		case (str.indexOf('蓝合双') !== -1):
			var obj = {
				alias:'HeAndSides',
				color:'blue',
				danShuang:'shuang',
			};
			nub = initFuc(obj,ball);
			break;
		case (str.indexOf('蓝合大') !== -1):
			var obj = {
				alias:'HeAndSides',
				color:'blue',
				daXiao:'da',
			};
			nub = initFuc(obj,ball);
			break;
		case (str.indexOf('蓝合小') !== -1):
			var obj = {
				alias:'HeAndSides',
				color:'blue',
				daXiao:'xiao',
			};
			nub = initFuc(obj,ball);
			break;
		case (str.indexOf('蓝单') !== -1):
			var obj = {
				alias:'BoSeAndSides',
				color:'blue',
				danShuang:'dan',
			};
			nub = initFuc(obj,ball);
			break;
		case (str.indexOf('蓝双') !== -1):
			var obj = {
				alias:'BoSeAndSides',
				color:'blue',
				danShuang:'shuang',
			};
			nub = initFuc(obj,ball);
			break;
		case (str.indexOf('蓝大') !== -1):
			var obj = {
				alias:'BoSeAndSides',
				color:'blue',
				daXiao:'da',
			};
			nub = initFuc(obj,ball);
			break;
		case (str.indexOf('蓝小') !== -1):
			var obj = {
				alias:'BoSeAndSides',
				color:'blue',
				daXiao:'xiao',
			};
			nub = initFuc(obj,ball);
			break;
		case (str.indexOf('合单') !== -1):
			var obj = {
				alias:'HeAndSides',
				danShuang:'dan',
			};
			nub = initFuc(obj,ball);
			break;
		case (str.indexOf('合双') !== -1):
			var obj = {
				alias:'HeAndSides',
				danShuang:'shuang',
			};
			nub = initFuc(obj,ball);
			break;
		case (str.indexOf('合大') !== -1):
			var obj = {
				alias:'HeAndSides',
				daXiao:'da',
			};
			nub = initFuc(obj,ball);
			break;
		case (str.indexOf('合小') !== -1):
			var obj = {
				alias:'HeAndSides',
				daXiao:'xiao',
			};
			nub = initFuc(obj,ball);
			break;
		case (str.indexOf('大单') !== -1):
			var obj = {
				alias:'BoSeAndSides',
				daXiao:'da',
				danShuang:'dan',
			};
			nub = initFuc(obj,ball);
			break;
		case (str.indexOf('小单') !== -1):
			var obj = {
				alias:'BoSeAndSides',
				daXiao:'xiao',
				danShuang:'dan',
			};
			nub = initFuc(obj,ball);
			break;
		case (str.indexOf('大双') !== -1):
			var obj = {
				alias:'BoSeAndSides',
				daXiao:'da',
				danShuang:'shuang',
			};
			nub = initFuc(obj,ball);
			break;
		case (str.indexOf('小双') !== -1):
			var obj = {
				alias:'BoSeAndSides',
				daXiao:'xiao',
				danShuang:'shuang',
			};
			nub = initFuc(obj,ball);
			break;
		case (str.indexOf('单') !== -1):
			var obj = {
				alias:'BoSeAndSides',
				danShuang:'dan',
			};
			nub = initFuc(obj,ball);
			break;
		case (str.indexOf('双') !== -1):
			var obj = {
				alias:'BoSeAndSides',
				danShuang:'shuang',
			};
			nub = initFuc(obj,ball);
			break;
		case (str.indexOf('大') !== -1):
			var obj = {
				alias:'BoSeAndSides',
				daXiao:'da',
			};
			nub = initFuc(obj,ball);
			break;
		case (str.indexOf('小') !== -1):
			var obj = {
				alias:'BoSeAndSides',
				daXiao:'xiao',
			};
			nub = initFuc(obj,ball);
			break;
		case (str.indexOf('头') !== -1):
			var obj = {
				alias:'TouToNo',
				code:str,
			};console.log('onTouToNo',str)
			nub = initFuc(obj,ball);
			break;
		case (str.indexOf('尾') !== -1):
			var obj = {
				alias:'WeiToNo',
				code:str,
			};
			nub = initFuc(obj,ball);
			break;
		case ((str.replace(/[^0-9]/ig,'') > 0)):
			var obj = {
				alias:'BallNo',
				code:str,
			};
			nub = initFuc(obj,ball);
			break;
		case ((new RegExp('鼠|兔|牛|虎|龙|蛇|马|羊|猴|鸡|狗|猪')).test(str)):
			var obj = {
				alias:'ZodiacToNo',
				code:str,
			};
			nub = initFuc(obj,ball);
			break;
		case ((new RegExp('家禽|野兽|吉美|凶丑|阴性|阳性|单笔|双笔|天肖|地肖|白边|黑中|女肖|男肖|琴|棋|书|画|五福肖|红肖|蓝肖|绿肖')).test(str)):
			var obj = {
				alias:'ShuXingToNo',
				code:str,
			};
			nub = initFuc(obj,ball);
			break;
		case ((new RegExp('金|木|水|火|土')).test(str)):
			var obj = {
				alias:'WuXingToNo',
				code:str,
			};
			nub = initFuc(obj,ball);
			break;
		
			
	}
	return nub;

}
var obj = {
	
	
	// 属性
	onShuXing:function(data,ball){
		let nub = [];
		ball.map(item=>{
			if(item.attr.indexOf(data.title) !== -1) {
				nub.push({
					color : item.color,
					nub : item.nub,
					title : item.title,
					key : item.key
				});
			}
		});
		return nub;
	},
	// 五行
	onWuXing:function(data,ball){
		let nub = [];
		ball.map(item=>{
			if(data.title == item.wuxing) {
				nub.push({
					color : item.color,
					nub : item.nub,
					title : item.title,
					key : item.key
				});
			}
		});
		return nub;
	},
	// 生肖
	onZodiac :function(data,ball){
		let nub = [];
		ball.map(item=>{
			if(data.title == item.title) {
				nub.push({
					color : item.color,
					nub : item.nub,
					title : item.title,
					key : item.key
				});
			}
		});
		return nub;
	},
	//波色
	onBoSe :function(data,ball){
		let nub = [];
		ball.map(item=>{
			if(data.color == item.color) {
				nub.push({
					color : item.color,
					nub : item.nub,
					title : item.title,
					key : item.key
				});
			}
		});
		return nub;
	},
	//波色 大、小、单、双
	onBoSeAndSides:function(data,ball){
		let nub = [];
		ball.map(item=>{
			if(
				(!data.color || (data.color == item.color))
				&& (!data.daXiao || (((data.daXiao == 'da' && parseInt(item.nub) >= 25) || (data.daXiao == 'xiao' && parseInt(item.nub) <= 24))))
				&& (!data.danShuang || ((data.danShuang == 'dan' && parseInt(item.nub) % 2 !== 0) || (data.danShuang == 'shuang' && parseInt(item.nub) % 2 === 0)))
			) {
				nub.push({
					color : item.color,
					nub : item.nub,
					title : item.title,
					key : item.key
				});
			}
		});
		return nub;
	},
	//合数 大、小、单、双
	onHeAndSides:function(data,ball){
		let nub = [];
		ball.map(item=>{
			var prefix = item.nub.substr(0,1);
			var suffix = item.nub.substr(-1);
			var he = parseInt(prefix) + parseInt(suffix);
			if(
				(!data.color || (data.color == item.color))
				&& (!data.daXiao || (((data.daXiao == 'da' && he > 6) || (data.daXiao == 'xiao' && he <= 6))))
				&& (!data.danShuang || ((data.danShuang == 'dan' && he % 2 !== 0) || (data.danShuang == 'shuang' && he % 2 === 0)))
			) {
				nub.push({
					color : item.color,
					nub : item.nub,
					title : item.title,
					key : item.key
				});
			}
		});
		return nub;
	},
	onBallNo:function(data,ball){
		let nub = [];
		let codeArr = data.code.split(',');
		ball.map(item=>{
			codeArr.map(vl=>{
				if(parseInt(item.nub) == parseInt(vl)) {
					nub.push({
						color : item.color,
						nub : item.nub,
						title : item.title,
						key : item.key
					});
				}
			})
		});
		return nub;
	},
	// 生肖
	onZodiacToNo :function(data,ball){
		let nub = [];
		ball.map(item=>{
			if(data.code.indexOf(item.title) !== -1) {
				nub.push({
					color : item.color,
					nub : item.nub,
					title : item.title,
					key : item.key
				});
			}
		});
		return nub;
	},
	// 属性
	onShuXingToNo:function(data,ball){
		let nub = [];
		ball.map(item=>{
			item.attr.map(vl=>{
				if(data.code.indexOf(vl) !== -1){
					nub.push({
						color : item.color,
						nub : item.nub,
						title : item.title,
						key : item.key,
						attr : vl
					});
				}
			});
		});
		return nub;
	},
	// 五行
	onWuXingToNo:function(data,ball){
		let nub = [];
		ball.map(item=>{
			if(data.code.indexOf(item.wuxing) !== -1) {
				nub.push({
					color : item.color,
					nub : item.nub,
					title : item.title,
					key : item.key,
					wuxing : item.wuxing
				});
			}
		});
		return nub;
	},
	onTouToNo:function(data,ball){
		
		let nub = [];
		let tou = data.code.substr(0,1);
		ball.map(item=>{
			var nubTou = item.nub.substr(0,1);
			
			if(Number(tou) === Number(nubTou)) {
				nub.push({
					color : item.color,
					nub : item.nub,
					title : item.title,
					key : item.key
				});
			}
		});
		return nub;
	},
	onWeiToNo:function(data,ball){
		let nub = [];
		let tou = data.code.substr(0,1);
		ball.map(item=>{
			var nubTou = item.nub.substr(-1);
			if(Number(tou) === Number(nubTou)) {
				nub.push({
					color : item.color,
					nub : item.nub,
					title : item.title,
					key : item.key
				});
			}
		});
		return nub;
	}
}